package com.owen.oauth2.client.connect;

import com.owen.oauth2.client.api.MyOAuth2;
import com.owen.oauth2.client.api.MyOAuth2UserInfo;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;

public class MyOAuth2Adapter implements ApiAdapter<MyOAuth2> {
    @Override
    public boolean test(MyOAuth2 api) {
        return true;
    }

    @Override
    public void setConnectionValues(MyOAuth2 api, ConnectionValues values) {
        MyOAuth2UserInfo userInfo = api.getUserInfo();
        values.setDisplayName(userInfo.getNickName());
        values.setImageUrl(userInfo.getNickName());
        values.setProfileUrl(userInfo.getProfileUrl());
        values.setProviderUserId(userInfo.getId());
    }

    @Override
    public UserProfile fetchUserProfile(MyOAuth2 api) {
        return null;
    }

    @Override
    public void updateStatus(MyOAuth2 api, String message) {

    }
}
